<!--  -->
<template>
  <div>
    <el-form
      label-width="60px"
      :rules="rules"
      :model="phone"
      ref="formRefPhone"
    >
      <el-form-item label="手机" prop="name">
        <el-input v-model="phone.name" />
      </el-form-item>
      <el-form-item label="验证" prop="password">
        <div class="password">
          <el-input v-model="phone.password" />
          <el-button type="primary" class="btn" @click="btnClick" ref="BTN"
            >获取验证码</el-button
          >
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { defineComponent, reactive, ref } from 'vue'
import { rules } from '../config/phone-config' //导入校验规则
export default defineComponent({
  setup() {
    const phone = reactive({
      name: '',
      password: ''
    })
    const btnClick = () => {
      console.log('获取验证码')
    }
    const formRefPhone = ref(null)
    const phoneLogin = () => {
      formRefPhone.value.validate((valid) => {
        if (valid) {
          console.log('手机登录')
        }
      })
    }
    return {
      phone,
      rules,
      btnClick,
      phoneLogin,
      formRefPhone
    }
  }
})
</script>
<style lang="less" scoped>
.password {
  display: flex;
}
.btn {
  margin-left: 8px;
}
</style>
